﻿package mortal.game.view.mainUI.smallMap.view.render
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.ui.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gLinkText.*;
    import mortal.game.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.view.common.*;
    import mortal.game.view.mainUI.smallMap.view.data.*;
    import mortal.mvc.core.*;

    public class SmallMapCustomXYRender extends GCellRenderer
    {
        private var _txtName:GTextFiled;
        private var _btnFlyBoot:FlyBoot;
        private var _line:ScaleBitmap;
        private var _myData:SmallMapCustomXYData;

        public function SmallMapCustomXYRender()
        {
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            this._myData = param1 as SmallMapCustomXYData;
            if (this._myData.isNotSet)
            {
                this._txtName.textColor = 16246466;
            }
            else
            {
                this._txtName.textColor = 5106285;
            }
            this._txtName.text = this._myData.name;
            if (this._myData.mapId > 0)
            {
                this._txtName.toolTipData = GameMapConfig.instance.getMapInfo(this._myData.mapId).name + "(" + this._myData.x.toString() + ", " + this._myData.y.toString() + ")";
            }
            this._txtName.mouseEnabled = !this._myData.isNotSet;
            return;
        }// end function

        private function clickNameTextHandler(event:MouseEvent) : void
        {
            AIManager.onAIControl(AIType.GoToOtherMap, Game.mapInfo.mapId, this._myData.mapId, new Point(this._myData.x, this._myData.y));
            return;
        }// end function

        private function mouseOverTextHandler(event:MouseEvent) : void
        {
            Mouse.cursor = MouseCursor.HAND;
            return;
        }// end function

        private function mouseOutTextHandler(event:MouseEvent) : void
        {
            Mouse.cursor = MouseCursor.ARROW;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatLv;
            _loc_1.underline = true;
            _loc_1.size = 12;
            this._txtName = UIFactory.gTextField("", 4, 3, 200, 24, this, _loc_1);
            this._btnFlyBoot = UICompomentPool.getUICompoment(FlyBoot) as FlyBoot;
            this._btnFlyBoot.x = 164;
            this._btnFlyBoot.y = 5;
            this.addChild(this._btnFlyBoot);
            this._line = UIFactory.bg(-8, 24, 220, 2, this, ImagesConst.SplitLine);
            this._btnFlyBoot.configEventListener(MouseEvent.CLICK, this.flyReqHandler);
            this.configEventListener(MouseEvent.CLICK, this.clickMeHandler);
            this._txtName.configEventListener(MouseEvent.CLICK, this.clickNameTextHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._txtName.dispose(param1);
            this._btnFlyBoot.dispose(param1);
            this._line.dispose(param1);
            this._txtName = null;
            this._btnFlyBoot = null;
            this._line = null;
            return;
        }// end function

        private function flyReqHandler(event:MouseEvent) : void
        {
            if (this._myData == null || this._myData.isNotSet)
            {
                return;
            }
            var _loc_2:* = new SPassTo();
            _loc_2.toPoint = new SPoint();
            _loc_2.toPoint.x = this._myData.x;
            _loc_2.toPoint.y = this._myData.y;
            _loc_2.mapId = this._myData.mapId;
            Dispatcher.dispatchEvent(new DataEvent(EventName.FlyBoot, _loc_2));
            return;
        }// end function

        private function clickMeHandler(event:MouseEvent) : void
        {
            if (this._myData == null || this._myData.isNotSet)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.SmallMapShowCustomMapPoinWin));
                return;
            }
            return;
        }// end function

    }
}
